// https://leetcode-cn.com/problems/symmetric-tree/
// 101. 对称二叉树
// 给定一个二叉树的根节点 root，判断它是否轴对称

import { TreeNode } from '../utils/index.ts';

function isSymmetric(root: TreeNode | null): boolean {
    return isMirror(root, root);

    function isMirror(root1: TreeNode | null, root2: TreeNode | null): boolean {
        if (root1 === null && root2 === null) return true;
        if (root1 === null || root2 === null) return false;
        return (
            root1.val === root2.val &&
            isMirror(root1.left, root2.right) &&
            isMirror(root1.right, root2.left)
        );
    }
}
